Skip to content

refactor: enable macos build workflow#217

Merged
1a1a11a merged 7 commits intodevelopfrom
1a1a11a/macos_build
Jun 23, 2025
Merged

refactor: enable macos build workflow#217
1a1a11a merged 7 commits intodevelopfrom
1a1a11a/macos_build

Conversation

@1a1a11a
Copy link
Copy Markdown
Owner

@1a1a11a 1a1a11a commented Jun 22, 2025

update macOS job configuration and upgrade checkout action to v4

@1a1a11a 1a1a11a requested a review from haochengxia as a code owner June 22, 2025 16:34
@trunk-io
Copy link
Copy Markdown

trunk-io Bot commented Jun 22, 2025

Merging to develop in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

@1a1a11a 1a1a11a changed the title refactor: update macOS job configuration and upgrade checkout action … refactor: enable macos build workflow Jun 22, 2025
cursor[bot]

This comment was marked as outdated.

@1a1a11a 1a1a11a marked this pull request as draft June 22, 2025 20:44
@1a1a11a 1a1a11a requested a review from Copilot June 22, 2025 20:44

This comment was marked as outdated.

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing CMake Configuration in macOS Job

The macOS job is missing the essential CMake configuration step. It attempts to build the project without first running cmake -B to initialize the build directory, which will cause the build to fail. This configuration step is correctly included in the ubuntu and selfhosted jobs.

.github/workflows/build.yml#L12-L27

jobs:
macos:
name: macos / clang
runs-on: macos-latest
env:
CC: clang
steps:
- uses: actions/checkout@v4
- name: Prepare
run: bash scripts/install_dependency.sh
- name: Build
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
- name: Test
working-directory: ${{github.workspace}}/build
run: |
ctest -C ${{env.BUILD_TYPE}} --output-on-failure

Fix in Cursor


Was this report helpful? Give feedback by reacting with 👍 or 👎

@1a1a11a 1a1a11a requested a review from Copilot June 22, 2025 20:49
@1a1a11a 1a1a11a self-assigned this Jun 22, 2025
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the macOS build workflow and updates the checkout action to version 4 across all jobs.

  • Uncomments and updates the macOS job with a new dependency installation script and switches from macos-10.15 to macos-latest.
  • Upgrades the actions/checkout step from v2 to v4 in macOS, Ubuntu, and self-hosted jobs.
Comments suppressed due to low confidence (3)

.github/workflows/build.yml:17

  • Upgrading to actions/checkout@v4 is a good update; please verify that any changes in default behaviors do not affect downstream steps.
      - uses: actions/checkout@v4

.github/workflows/build.yml:32

  • Upgrading to actions/checkout@v4 is a good update; please verify that any changes in default behaviors do not affect downstream steps.
      - uses: actions/checkout@v4

.github/workflows/build.yml:52

  • Upgrading to actions/checkout@v4 is a good update; please verify that any changes in default behaviors do not affect downstream steps.
      - uses: actions/checkout@v4

# run: make test
macos:
name: macos / clang
runs-on: macos-latest
Copy link

Copilot AI Jun 22, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using 'macos-latest' may lead to varying build environments over time; consider pinning to a specific macOS version to ensure consistent builds if required.

Suggested change
runs-on: macos-latest
runs-on: macos-12

Copilot uses AI. Check for mistakes.
@1a1a11a
Copy link
Copy Markdown
Owner Author

1a1a11a commented Jun 22, 2025

Not sure why the test results are not correct.

@laustam
Copy link
Copy Markdown
Contributor

laustam commented Jun 23, 2025

Might the test be failing due to a different RNG implementation on macOS?

@1a1a11a
Copy link
Copy Markdown
Owner Author

1a1a11a commented Jun 23, 2025

Might the test be failing due to a different RNG implementation on macOS?

I thought about this, but LRU does not use RNG, or is there a hidden one that I missed?

@laustam
Copy link
Copy Markdown
Contributor

laustam commented Jun 23, 2025

ERROR:/Users/runner/work/libCacheSim/libCacheSim/test/test_evictionAlgo.c:17:_verify_profiler_results: assertion failed (miss_cnt_true[i] == res[i].n_miss): (89776 == 89582)
Cacheus uint64_t cache_size[] = {134217728, 268435456, 402653184, 536870[91](https://github.com/1a1a11a/libCacheSim/actions/runs/15810660836/job/44561516073?pr=217#step:6:92)2, 671088640, 805306368, 939524096, 1073741824};
uint64_t miss_cnt_true[] = {89582, 82491, 80140, 72970, 69329, 69147, 68022, 66158};
uint64_t miss_byte_true[] = {4046596096, 3724201472, 3557762560, 3182379008, 2981198336, 2964742144, 28678[92](https://github.com/1a1a11a/libCacheSim/actions/runs/15810660836/job/44561516073?pr=217#step:6:93)736, 2791617536};
not ok /libCacheSim/cacheAlgo_Cacheus - ERROR:/Users/runner/work/libCacheSim/libCacheSim/test/test_evictionAlgo.c:17:_verify_profiler_results: assertion failed (miss_cnt_true[i] == res[i].n_miss): (89776 == 89582)
Bail out!

It seems that the LRU test passes, and that Cacheus is the problematic test (we can see this from the print_results debug prints). I briefly checked the Cacheus implementation, and there is some use of RNG there

@haochengxia
Copy link
Copy Markdown
Collaborator

ERROR:/Users/runner/work/libCacheSim/libCacheSim/test/test_evictionAlgo.c:17:_verify_profiler_results: assertion failed (miss_cnt_true[i] == res[i].n_miss): (89776 == 89582)
Cacheus uint64_t cache_size[] = {134217728, 268435456, 402653184, 536870[91](https://github.com/1a1a11a/libCacheSim/actions/runs/15810660836/job/44561516073?pr=217#step:6:92)2, 671088640, 805306368, 939524096, 1073741824};
uint64_t miss_cnt_true[] = {89582, 82491, 80140, 72970, 69329, 69147, 68022, 66158};
uint64_t miss_byte_true[] = {4046596096, 3724201472, 3557762560, 3182379008, 2981198336, 2964742144, 28678[92](https://github.com/1a1a11a/libCacheSim/actions/runs/15810660836/job/44561516073?pr=217#step:6:93)736, 2791617536};
not ok /libCacheSim/cacheAlgo_Cacheus - ERROR:/Users/runner/work/libCacheSim/libCacheSim/test/test_evictionAlgo.c:17:_verify_profiler_results: assertion failed (miss_cnt_true[i] == res[i].n_miss): (89776 == 89582)
Bail out!

It seems that the LRU test passes, and that Cacheus is the problematic test (we can see this from the print_results debug prints). I briefly checked the Cacheus implementation, and there is some use of RNG there

While LeCaR uses RNG as well, it passed the test.

@haochengxia
Copy link
Copy Markdown
Collaborator

haochengxia commented Jun 23, 2025

Confirmed the difference is from RNG which makes lr different

# Mac
[Cacheus][macOS] Init: ghost_list_factor=1.00, update_interval=1073741824, lr=0.374000, w_lru=0.50, w_lfu=0.50, cache_size=1073741824, hashpower=20
[Cacheus][macOS] LRU=0x105808a00, LFU=0x130018600, LRU_g=0x130019400, LFU_g=0x13001a200
[Cacheus][macOS] sizeof(Cacheus_params_t)=112

# Ubuntu
[Cacheus][Linux] Init: ghost_list_factor=1.00, update_interval=1073741824, lr=0.276000, w_lru=0.50, w_lfu=0.50, cache_size=1073741824, hashpower=20
[Cacheus][Linux] LRU=0x55f84403ad00, LFU=0x55f84403ee00, LRU_g=0x55f84403e100, LFU_g=0x55f845bb6000
[Cacheus][Linux] sizeof(Cacheus_params_t)=112

dump rand() in test_evictionAlgo.c

int main(int argc, char *argv[]) {
  g_test_init(&argc, &argv, NULL);
  srand(0);  // for reproducibility
  printf("rand() = %d\n", rand());
### Mac
# random seed: R02Scbb0a3dd5ce5dd47fd2d2ff21f064356
rand() = 520932930

### Ubuntu
# random seed: R02Sf907d52631b1852990966e465debb2f8
rand() = 1804289383

@1a1a11a
Copy link
Copy Markdown
Owner Author

1a1a11a commented Jun 23, 2025

Confirmed the difference is from RNG which makes lr different

# Mac
[Cacheus][macOS] Init: ghost_list_factor=1.00, update_interval=1073741824, lr=0.374000, w_lru=0.50, w_lfu=0.50, cache_size=1073741824, hashpower=20
[Cacheus][macOS] LRU=0x105808a00, LFU=0x130018600, LRU_g=0x130019400, LFU_g=0x13001a200
[Cacheus][macOS] sizeof(Cacheus_params_t)=112

# Ubuntu
[Cacheus][Linux] Init: ghost_list_factor=1.00, update_interval=1073741824, lr=0.276000, w_lru=0.50, w_lfu=0.50, cache_size=1073741824, hashpower=20
[Cacheus][Linux] LRU=0x55f84403ad00, LFU=0x55f84403ee00, LRU_g=0x55f84403e100, LFU_g=0x55f845bb6000
[Cacheus][Linux] sizeof(Cacheus_params_t)=112

dump rand() in test_evictionAlgo.c

int main(int argc, char *argv[]) {
  g_test_init(&argc, &argv, NULL);
  srand(0);  // for reproducibility
  printf("rand() = %d\n", rand());
### Mac
# random seed: R02Scbb0a3dd5ce5dd47fd2d2ff21f064356
rand() = 520932930

### Ubuntu
# random seed: R02Sf907d52631b1852990966e465debb2f8
rand() = 1804289383
ERROR:/Users/runner/work/libCacheSim/libCacheSim/test/test_evictionAlgo.c:17:_verify_profiler_results: assertion failed (miss_cnt_true[i] == res[i].n_miss): (89776 == 89582)
Cacheus uint64_t cache_size[] = {134217728, 268435456, 402653184, 536870[91](https://github.com/1a1a11a/libCacheSim/actions/runs/15810660836/job/44561516073?pr=217#step:6:92)2, 671088640, 805306368, 939524096, 1073741824};
uint64_t miss_cnt_true[] = {89582, 82491, 80140, 72970, 69329, 69147, 68022, 66158};
uint64_t miss_byte_true[] = {4046596096, 3724201472, 3557762560, 3182379008, 2981198336, 2964742144, 28678[92](https://github.com/1a1a11a/libCacheSim/actions/runs/15810660836/job/44561516073?pr=217#step:6:93)736, 2791617536};
not ok /libCacheSim/cacheAlgo_Cacheus - ERROR:/Users/runner/work/libCacheSim/libCacheSim/test/test_evictionAlgo.c:17:_verify_profiler_results: assertion failed (miss_cnt_true[i] == res[i].n_miss): (89776 == 89582)
Bail out!

It seems that the LRU test passes, and that Cacheus is the problematic test (we can see this from the print_results debug prints). I briefly checked the Cacheus implementation, and there is some use of RNG there

Oh, I read it wrong. Yes, it looks like RNG is the reason. We have an internal fast and deterministic RNG, do you want to submit a PR to fix it?

@1a1a11a
Copy link
Copy Markdown
Owner Author

1a1a11a commented Jun 23, 2025

Confirmed the difference is from RNG which makes lr different

# Mac
[Cacheus][macOS] Init: ghost_list_factor=1.00, update_interval=1073741824, lr=0.374000, w_lru=0.50, w_lfu=0.50, cache_size=1073741824, hashpower=20
[Cacheus][macOS] LRU=0x105808a00, LFU=0x130018600, LRU_g=0x130019400, LFU_g=0x13001a200
[Cacheus][macOS] sizeof(Cacheus_params_t)=112

# Ubuntu
[Cacheus][Linux] Init: ghost_list_factor=1.00, update_interval=1073741824, lr=0.276000, w_lru=0.50, w_lfu=0.50, cache_size=1073741824, hashpower=20
[Cacheus][Linux] LRU=0x55f84403ad00, LFU=0x55f84403ee00, LRU_g=0x55f84403e100, LFU_g=0x55f845bb6000
[Cacheus][Linux] sizeof(Cacheus_params_t)=112

dump rand() in test_evictionAlgo.c

int main(int argc, char *argv[]) {
  g_test_init(&argc, &argv, NULL);
  srand(0);  // for reproducibility
  printf("rand() = %d\n", rand());
### Mac
# random seed: R02Scbb0a3dd5ce5dd47fd2d2ff21f064356
rand() = 520932930

### Ubuntu
# random seed: R02Sf907d52631b1852990966e465debb2f8
rand() = 1804289383

Thank you for confirming this!

@1a1a11a
Copy link
Copy Markdown
Owner Author

1a1a11a commented Jun 23, 2025

Confirmed the difference is from RNG which makes lr different

# Mac
[Cacheus][macOS] Init: ghost_list_factor=1.00, update_interval=1073741824, lr=0.374000, w_lru=0.50, w_lfu=0.50, cache_size=1073741824, hashpower=20
[Cacheus][macOS] LRU=0x105808a00, LFU=0x130018600, LRU_g=0x130019400, LFU_g=0x13001a200
[Cacheus][macOS] sizeof(Cacheus_params_t)=112

# Ubuntu
[Cacheus][Linux] Init: ghost_list_factor=1.00, update_interval=1073741824, lr=0.276000, w_lru=0.50, w_lfu=0.50, cache_size=1073741824, hashpower=20
[Cacheus][Linux] LRU=0x55f84403ad00, LFU=0x55f84403ee00, LRU_g=0x55f84403e100, LFU_g=0x55f845bb6000
[Cacheus][Linux] sizeof(Cacheus_params_t)=112

dump rand() in test_evictionAlgo.c

int main(int argc, char *argv[]) {
  g_test_init(&argc, &argv, NULL);
  srand(0);  // for reproducibility
  printf("rand() = %d\n", rand());
### Mac
# random seed: R02Scbb0a3dd5ce5dd47fd2d2ff21f064356
rand() = 520932930

### Ubuntu
# random seed: R02Sf907d52631b1852990966e465debb2f8
rand() = 1804289383
ERROR:/Users/runner/work/libCacheSim/libCacheSim/test/test_evictionAlgo.c:17:_verify_profiler_results: assertion failed (miss_cnt_true[i] == res[i].n_miss): (89776 == 89582)
Cacheus uint64_t cache_size[] = {134217728, 268435456, 402653184, 536870[91](https://github.com/1a1a11a/libCacheSim/actions/runs/15810660836/job/44561516073?pr=217#step:6:92)2, 671088640, 805306368, 939524096, 1073741824};
uint64_t miss_cnt_true[] = {89582, 82491, 80140, 72970, 69329, 69147, 68022, 66158};
uint64_t miss_byte_true[] = {4046596096, 3724201472, 3557762560, 3182379008, 2981198336, 2964742144, 28678[92](https://github.com/1a1a11a/libCacheSim/actions/runs/15810660836/job/44561516073?pr=217#step:6:93)736, 2791617536};
not ok /libCacheSim/cacheAlgo_Cacheus - ERROR:/Users/runner/work/libCacheSim/libCacheSim/test/test_evictionAlgo.c:17:_verify_profiler_results: assertion failed (miss_cnt_true[i] == res[i].n_miss): (89776 == 89582)
Bail out!

It seems that the LRU test passes, and that Cacheus is the problematic test (we can see this from the print_results debug prints). I briefly checked the Cacheus implementation, and there is some use of RNG there

Oh, I read it wrong. Yes, it looks like RNG is the reason. We have an internal fast and deterministic RNG, do you want to submit a PR to fix it?

At first glance, CACHEUS uses the internal RNG, so probably need to dig deeper.

@haochengxia
Copy link
Copy Markdown
Collaborator

  • Pin the seed for internal RNG
  • Change print_result since the output is simulated results instead of fixed reference results

@1a1a11a
Copy link
Copy Markdown
Owner Author

1a1a11a commented Jun 23, 2025

  • Pin the seed for internal RNG
  • Change print_result since the output is simulated results instead of fixed reference results

Thank you! Does it only affect CACHEUS?

@1a1a11a 1a1a11a marked this pull request as ready for review June 23, 2025 19:56
@1a1a11a 1a1a11a merged commit 17fc4ec into develop Jun 23, 2025
9 checks passed
@haochengxia
Copy link
Copy Markdown
Collaborator

  • Pin the seed for internal RNG
  • Change print_result since the output is simulated results instead of fixed reference results

Thank you! Does it only affect CACHEUS?

Yes. Only CacheUs is affected by the initial state of RNG

@1a1a11a 1a1a11a deleted the 1a1a11a/macos_build branch June 25, 2025 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants